{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="tabs clearfix">
    <a href="javascript:;" class="active tabs_a fl" data-origin="additem" data-index="1">基本信息</a>
	<a href="javascript:;" class="tabs_a fl" data-origin="additem" data-index="2">{$ITEM_NAME}属性</a>
    <a href="javascript:;" class="tabs_a fl" data-origin="additem" data-index="3">详细描述</a>
</div>
<!-- end tabs -->
<div class="tabs-content" data-origin="additem">
<form method="post" id="form_addItem" enctype="multipart/form-data">
<div class="tc hide" data-index="3">
    <div class="formitems inline">
        <label class="fi-name"><!-- <span class="colorRed">*</span> -->{$ITEM_NAME}详情：</label>
        <div class="form-controls">
            <textarea name="contents" id="contents" class="large">{$contents}</textarea>
            <span class="fi-help-text error"></span>
        </div>
    </div>
    <div class="formactions mgl180">
        <button class="btn btn-blue"><i class="gicon-ok white"></i>提交</button>
    </div>
</div>
<!-- end 详细描述 -->
			<table class='hide' class='display:none;' id='J_add_sku_rank_price'>
				{foreach from=$arr_agent_rank item=row}
				<tr>
                	<td class="tables-form-title">{$row.rank_name}</td>
                    <td>
                        <input type="hidden" name="new_sku_rank_id[]" value="{$row.agent_rank_id}">
                        <input type="text" class="mini" name="new_sku_rank_price[]" value="">元
                    </td>
                </tr>
                {/foreach}
            </table>
<div class="tc hide" data-index="2">
    <div id="J_item_prop">
    {if $type_id == 0}
    <p class="edit_item_tip">设置商品属性前，请先选择商品类型。</p>
    {else}
    <div class="formitems inline">
        <label class="fi-name">商品扩展属性：</label>
        <div class="form-controls">
            <ul id="j-item-extend">
                {foreach from=$arr_extend_prop item=row1}
                <li>
                    <label><input type="checkbox" data-id="{$row1.property_name}" class="checkbox" name="extend_prop_id[]" value="{$row1.property_id}"
                        {if isset($row1.checked)}checked{/if}>{$row1.property_name}</label>
                    <select name="extend_prop_value[]" {if !isset($row1.checked)}disabled{/if}>
                    <option value="">--请选择--</option>
                    {foreach from=$row1.prop_value item=row2}
                    <option value="{$row2.property_value_id}" data-serial="{$row2.serial}"
                    {if isset($row2.selected)}selected{/if}>{$row2.property_value}</option>
                    {/foreach}
                    </select>
                    <span class="fi-help-text inline hide"></span>
                    <a href="###" data-prop="{$row1.property_id}" class="btn btn-blue j-showExtValPanel">添加值</a>
                </li>
                {/foreach}
                <li class="J_li_add_extend">
                    <label></label>
                    <button class="btn btn-orange" id="J_add_extend_prop">添加扩展属性</button>
                </li>
            </ul>
        </div>
    </div>
    <div class="formitems inline">
        <label class="fi-name">商品规格属性：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" name="has_sku" class="j-skupanelCtrl" value="0" {if !$item.has_sku}checked{/if}>关闭</label>
                <label><input type="radio" name="has_sku" class="j-skupanelCtrl" value="1" {if $item.has_sku}checked{/if}>开启</label>
            </div>
        </div>
    </div>
				<table class='hide' class='display:none;' id='J_add_sku_rank_price'>
				{foreach from=$arr_agent_rank item=row}
				<tr>
                	<td class="tables-form-title">{$row.rank_name}</td>
                    <td>
                        <input type="hidden" name="new_sku_rank_id[]" value="{$row.agent_rank_id}">
                        <input type="text" class="mini" name="new_sku_rank_price[]" value="">元
                    </td>
                </tr>
                {/foreach}
                </table>

    <div class="tablesWrap" id="j-skupanel" {if !$item.has_sku || $sku_num == 0}style="display:none;"{/if}>
        <div class="tables-searchbox">
            <a href="javascript:;" class="btn btn-blue" id="j-createPartsku">生成部分规格</a>
            <a href="javascript:;" class="btn btn-blue J_add_sku">增加一个规格</a>
        </div>
        <!-- end tables-searchbox -->
        <table class="wxtables">
            <colgroup>
                {foreach from=$arr_sku item=row}
                <col width="12%">
                {/foreach}
                <col width="12%">
                <col width="12%">
                <col width="12%">
                <col width="{if count($arr_sku) == 1}34{else}14{/if}%">
            </colgroup>
            <thead>
            <tr>
                {foreach from=$arr_sku item=row}
                <td>{$row.property_name}</td>
                {/foreach}
                <td>货号</td>
                <td>库存</td>
                <td>商品价格</td>
                <td>操作</td>
            </tr>
            </thead>
            <tbody class="J_sku_tbody">
            {foreach from=$arr_item_sku item=row}
            <tr data-value='{$row.item_sku_price_id}' class='J_sku_show'>
            <input type='hidden' name='sku_ids[]' value='{$row.item_sku_price_id}'>
                {foreach from=$arr_sku item=row1 key=key}
                <td>
                    
                    <select class="small sku{$key}" name="sku{$key}[]" >
                        <option value="0">选择{$row1.property_name}</option>
                        {if $key == 0}
                        {foreach from=$row1.prop_value item=row2}
                        <option value="{$row2.property_value_id}"
                        {if $row.property_value1 == $row2.property_value_id}selected{/if}
                        >{$row2.property_value}</option>
                        {/foreach}
                        {else}
                        {foreach from=$row1.prop_value item=row2}
                        <option value="{$row2.property_value_id}"
                        {if $row.property_value2 == $row2.property_value_id}selected{/if}
                        >{$row2.property_value}</option>
                        {/foreach}
                        {/if}
                    </select>
                </td>
                {/foreach}
                <td><input type="text" class='small sku_sn' name="sku_sn[]" value="{$row.item_sn}"></td>
                <td><input type="text" class="small sku_stock" name="sku_stock[]" value="{$row.sku_stock}"></td>
                <td><input type="text" class="sku_price" name="sku_price[]" value="{$row.sku_price}"></td>
                <td>
                	<a href="javascript:;" class="btn J_sku_del" title="删除">删除</a>
                </td>
            </tr>
            <tr id='hide_{$row.item_sku_price_id}' style='display:none;'>
            	<td colspan='4'></td>
            	<td colspan='2' style='text-align:right;'>
            		<table class="wxtables tables-form" style="width: 230px;margin:0">
                		<colgroup>
                    		<col width="10%">
                    		<col width="20%">
                		</colgroup>
                		<tbody>
                		{$sku_rank_price = $row.sku_rank_price}
               			{foreach from=$sku_rank_price item=row3 key=key3}
                		<tr>
                    		<td class="tables-form-title">{$row3.rank_name}</td>
                    		<td>
                        		<input type="hidden" name="sku_rank_id_{$row.item_sku_price_id}[]" value="{$row3.agent_rank_id}">
                        		<input type="text" class="mini" name="sku_rank_price_{$row.item_sku_price_id}[]" value="{$row3.price}">元
                    		</td>
                		</tr>
                		{/foreach}
                		</tbody>
            		</table>
            		(如果不填写，则该级别默认取本规格的定价)
            	</td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        <!-- end wxtables -->
    </div>
    <div hidden="hidden" id="J_type_sku">
        {foreach from=$arr_sku item=row1 key=key}
            <div hidden="hidden" id="J_sku{$key}_select">
                <select class="small" name="J_sku{$key}[]">
                    <option value="0">选择{$row1.property_name}</option>
                    {foreach from=$row1.prop_value item=row2}
                    <option value="{$row2.property_value_id}">{$row2.property_value}</option>
                    {/foreach}
                </select>
            </div>
        <div class="formitems inline">
            <label class="fi-name">{$row1.property_name}：</label> 
            <div class="form-controls">
                <div class="checkbox-group">
                    {foreach from=$row1.prop_value item=row2}
                    <label><input type="checkbox" name="skuValue{$key}[]" value="{$row2.property_value_id}">{$row2.property_value}</label>
                    {/foreach}
                </div>
                <span class="fi-help-text error"></span>
            </div>
        </div>
        {/foreach}
    </div>
    <!-- end tablesWrap -->
    {/if}
    </div>
    <div class="formactions mgl180">
        <span class="btn btn-blue jump" data-value='3'>下一步</span>
        <button class="btn" type="reset"><i class="gicon-repeat"></i>重置</button>
    </div>

</div>
<!-- end 规格属性 -->
<div class="tc" data-index="1">
        <div class="formitems inline">
            <label class="fi-name">
                <span class="colorRed">*</span>{$ITEM_NAME}分类：</label>
            <div class="form-controls">
                <select name="category_id">
                    <option value="">--请选择--</option>
                    {foreach from=$arr_category item=row1}
					<option value="{$row1.class_id}.0"
						{if $item.class_id == $row1.class_id && $item.sort_id == 0}
						selected
						{/if}
					>{$row1.class_name}</option>
                    {foreach from=$row1.sort_info item=row2}
					<option value="{$row1.class_id}.{$row2.sort_id}"
						{if $item.class_id == $row1.class_id && $item.sort_id == $row2.sort_id}
						selected
						{/if}
					>{$row2.sort_name}</option>
                    <!--{foreach from=$row2.genre_info item=row3}
                    <option value="{$row1.class_id}.{$row2.class_sort_id}.{$row3.class_genre_id}">{$row3.genre_name}</option>
					{/foreach}-->
                    {/foreach}
                    {/foreach}
                </select>
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <div class="formitems inline">
            <label class="fi-name">
                商品类型：</label>
            <div class="form-controls">
                <select name="item_type_id">
                    <option value="0">--请选择--</option>
                    {foreach from=$arr_type item=row}
                    <option value="{$row.item_type_id}" {if $row.item_type_id == $item.item_type_id}selected{/if}>{$row.item_type_name}</option>
                    {/foreach}
                </select>
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <!--
        <div class="formitems inline">
            <label class="fi-name"><span class="colorRed">*</span>是否为礼品：</label>
            <div class="form-controls">
                <div class="radio-group">
                    <label><input type="radio" name="is_gift" value="1"{if $item.is_gift == '1'} checked{/if}>礼品</label>
                    <label><input type="radio" name="is_gift" value="0"{if $item.is_gift == '0'} checked{/if}>商品</label>
                </div>
                <span class="fi-help-text error"></span>
            </div>
        </div>
        -->
        <input type="hidden" name="is_gift" value="0">

        <!--
        <div class="formitems inline">
            <label class="fi-name">
                品牌：</label>
            <div class="form-controls">
                <select name="brand_id">
                    <option value="0">--请选择--</option>
                    {foreach from=$brand_list item=row}
                    <option value="{$row.brand_id}"{if $row.brand_id == $item.brand_id} selected{/if}>{$row.brand_name}</option>
                    {/foreach}
                </select>
                <span class="fi-help-text error"></span>
            </div>
        </div>
        -->

        <div class="formitems inline">
            <label class="fi-name">
                <span class="colorRed">*</span>{$ITEM_NAME}名称：</label>
            <div class="form-controls">
				<input type="text" placeholder="请输入{$ITEM_NAME}名称" class="xxlarge" name="item_name" value="{$item.item_name}">
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <div class="formitems inline">
            <label class="fi-name">
                <span class="colorRed">*</span>{$ITEM_NAME}货号：</label>
            <div class="form-controls">
                <input type="text" placeholder="请输入{$ITEM_NAME}货号" class="small" name="item_sn" value="{$item.item_sn}">
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <div class="formitems inline">
            <label class="fi-name"><span class="colorRed">*</span>排序号：</label>
            <div class="form-controls">
                <input type="text" placeholder="0" class="small" name="serial" id="serial" value="{$item.serial}">
                <span class="fi-help-text hide"></span>
            </div>
        </div>
        <!-- <div class="formitems inline">
            <label class="fi-name">
                成本价：</label>
            <div class="form-controls">
				<input type="text" placeholder="0" class="small" name="cost_price" value="{$item.cost_price}">
                <span class="fi-text">元</span>
                <span class="fi-help-text error"></span>
            </div>
        </div> -->

        <div class="formitems inline">
            <label class="fi-name">
                市场价：</label>
            <div class="form-controls">
                <input type="text" placeholder="0" class="small" name="market_price" value="{$item.market_price}">
                <span class="fi-text">元</span>
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <div class="formitems inline">
            <label class="fi-name"><span class="colorRed">*</span>
                本店价：</label>
            <div class="form-controls">
				<input type="text" placeholder="0" class="small" name="mall_price" value="{$item.mall_price}">
                <span class="fi-text">元</span>
                <span class="fi-help-text error"></span>
            </div>
        </div>
        <!--
        <div class="formitems inline">
            <label class="fi-name">
                市场价：</label>
            <div class="form-controls">
                <input type="text" placeholder="0" class="small" name="market_price" value="{$item.market_price}">
                <span class="fi-text">元</span>
                <span class="fi-help-text error"></span>
            </div>
        </div>


        <div class="formitems inline">
            <label class="fi-name">
                积分抵扣百分比：</label>
            <div class="form-controls">
                <input type="text" placeholder="0" class="small" name="integral_exchange_rate" value="{$item.integral_exchange_rate}">
                <span class="fi-text">%</span>
                <span class="fi-help-text error"></span>
            </div>
        </div>
        -->
        <div class="formitems inline">
            <label class="fi-name">
                积分抵扣：</label>
            <div class="form-controls">
                <input type="text" placeholder="0" class="small" name="integral_exchange" value="{$item.integral_exchange}" >
                <span class="fi-help-text error"></span>
            </div>
        </div>
        <div class="formitems inline">
            <label class="fi-name">
                <span class="colorRed">*</span>库存数量：</label>
            <div class="form-controls">
				<input type="text" placeholder="0" class="small" name="stock" value="{$item.stock}">
                <span class="fi-help-text error"></span>
            </div>
        </div>
        <div class="formitems inline">
            <label class="fi-name">
                警戒库存：</label>
            <div class="form-controls">
				<input type="text" placeholder="0" class="small" name="stock_alarm" value="{$item.stock_alarm}">
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <div class="formitems inline">
            <label class="fi-name">
                {$ITEM_NAME}重量：</label>
            <div class="form-controls">
				<input type="text" placeholder="0" class="small" name="weight" value="{$item.weight}">
                <span class="fi-text">克</span>
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <!--
        <div class="formitems inline">
            <label class="fi-name">
                单位：</label>
            <div class="form-controls">
                <input type="text" placeholder="0" class="small" name="unit" value="{$item.unit}">
                <span class="fi-help-text error"></span>
            </div>
        </div>
        -->

		<!-- <div class="formitems inline">
			<label class="fi-name">温度说明：</label>
			<div class="form-controls">
				<textarea name="t_desc" style="height:50px;width:400px;" rows="3" cols="50">{$item.t_desc}</textarea>
				<span class="fi-help-text">商品是种子时填写</span>
			</div>
		</div>

		<div class="formitems inline">
			<label class="fi-name">水分说明：</label>
			<div class="form-controls">
				<textarea name="h_desc" style="height:50px;width:400px;" rows="3" cols="50">{$item.h_desc}</textarea>
				<span class="fi-help-text">商品是种子时填写</span>
			</div>
		</div>

		<div class="formitems inline">
			<label class="fi-name">光照说明：</label>
			<div class="form-controls">
				<textarea name="i_desc" style="height:50px;width:400px;" rows="3" cols="50">{$item.i_desc}</textarea>
				<span class="fi-help-text">商品是种子时填写</span>
			</div>
		</div> -->

		<div class="formitems inline">
			<label class="fi-name"><span class="colorRed">*</span>{$ITEM_NAME}销售状态：</label>
			<div class="form-controls">
				<div class="radio-group">
					<label><input type="radio" name="isuse" value="1" {if $item.isuse == 1}checked {/if}>出售中</label>
					<label><input type="radio" name="isuse" value="0" {if $item.isuse == 0}checked {/if}>仓库中</label>
				</div>
				<span class="fi-help-text error"></span>
			</div>
		</div>
        <div class="formitems inline">
            <label class="fi-name">积分商品：</label>
            <div class="form-controls">
                <div class="radio-group">
                    <label><input type="radio" name="is_integral" value="0" {if $item.is_integral == 0}checked {/if} onclick="all_integral(this.value)">否</label>
                    <label><input type="radio" name="is_integral" value="1" {if $item.is_integral == 1}checked {/if} onclick="all_integral(this.value)">是</label>
                </div>
                <span class="fi-help-text error"></span>
            </div>
        </div>
        <div class="formitems inline">
            <label class="fi-name"><span class="colorRed">*</span>{$ITEM_NAME}是否推荐（显示在首页）：</label>
            <div class="form-controls">
                <div class="radio-group">
                    <label><input type="radio" name="is_recommend" value="0" {if $item.is_recommend == 0}checked {/if}>否</label>
                    <label><input type="radio" name="is_recommend" value="1" {if $item.is_recommend == 1}checked {/if}>是</label>
                </div>
                <span class="fi-help-text error"></span>
            </div>
        </div>

        <div class="formitems inline">
            <label class="fi-name">{$ITEM_NAME}简介：</label>
            <div class="form-controls">
                <textarea name="item_desc" id="item_desc">{$item.item_desc}</textarea>
                <span class="fi-help-text">一般在200字以内, 在微商城的详情页面展示</span>
            </div>
        </div>

		{upload_image_widget($pic_data)}

        <div class="formactions mgl180">
            <input type="hidden" name="old_photo" value="{$old_photo}">
            <input type="hidden" name="act" value="edit">
            <span class="btn btn-blue jump" data-value='2'>下一步</span>
        </div>
</div>

<!-- end 基本信息 -->
</form>
</div>
{/block}
{block name="css"}
{literal}
<style>
    #jpops .fi-name{width:65px;}
    #jpops .form-controls{margin-left:75px;}
    #j-item-extend li{margin-bottom:10px;}
    .edit_item_tip{font-size: 18px;color: #a0a0a0;background-color: inherit;text-decoration: none;margin: 20px 180px;}
</style>
{/literal}
{/block}
{block name="js"}
<script>
var item_name = '{$ITEM_NAME}';
</script>
<script src="__KD__/kindeditor.js?version={$version}" > </script>
<script src="__KD__/lang/zh_CN.js?version={$version}" > </script>
<script src="__ACPJS__/AcpItem/add_item.js?version={$version}"></script>
<script src="__ACPJS__/AcpItem/add_item_validate.js?version={$version}"></script>
<script src="__ACPJS__/AcpItem/add_item_step1.js?version={$version}"></script>
<script src="__ACPJS__/AcpItem/add_item_step2.js?version={$version}"></script>
<script src="__ACPJS__/AcpItem/add_item_step3.js?version={$version}"></script>
<!--<script src="__ACPJS__/AcpItem/add_item_step4.js?version={$version}"></script>-->
<script src='/Public/Js/common/upload_image.js?version={$version}'></script>
<script>
{if !$arr_item_sku}
    $("#J_item_prop").html('');
    get_properys({$item.item_type_id});
{/if}
    var flag = 0;
    upload_batch_image('pic');
</script>
{/block}
